#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "../ourhdr.h"

int main(void)
{
    umask(0);
    if(creat("foo", S_IRUSR | S_IWUSR | S_IRGRP |S_IWGRP|
        S_IROTH | S_IWOTH) <0)
    {
        err_sys("create error for foo");
    }

    umask(S_IRGRP| S_IWGRP| S_IROTH| S_IWOTH);

    if(creat("bar", S_IRUSR | S_IWUSR |  S_IRGRP |S_IWGRP|
        S_IROTH | S_IWOTH) < 0)
    {
        err_sys("create error for bar");
    }
    exit(0);

    /***
     * 执行结果
zhaofeng@bogon 04 % ls -al
total 144
drwxr-xr-x  13 zhaofeng  staff    416  7 12 20:08 .
drwxr-xr-x  13 zhaofeng  staff    416  7  9 13:58 ..
-rw-------   1 zhaofeng  staff      0  7 12 20:08 bar
-rw-rw-rw-   1 zhaofeng  staff      0  7 12 20:08 foo
***/
}